package db;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @ClassName: DBSession
 * @Author: Leo
 * @Description:
 * @Date: 2019/4/18 14:42
 */
public class DBSession {
    private static final String resource = "mybatis-config.xml";

    public static SqlSession getSession() {
        InputStream is = null;
        try {
            is = Resources.getResourceAsStream(resource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new SqlSessionFactoryBuilder().build(is).openSession();
    }
}
